{
    //TS基本数据类型
    let bool: boolean = true
    let num1: number = 1
    let str: string = 'abc'
    let a: null = null
    let b: undefined = undefined
    let num2: bigint = 1n
    let sy1: symbol = Symbol('sy1')
    //代表当前的类型是数租，并且值为number
    const arr1: number[] = [1, 2, 3, 4, 5]
    //联合类型的数组
    const arr2: (number | string)[] = ["1", 2, "3", 4]
    arr2.push(3)
    //使用泛型定义数组类型
    const arr4: Array<number> = [1, 2, 3, 4, 5]
    //元祖Tuple：在js中可以人为是一个已知长度和已知类型的数组
    const tuple1: [number, boolean] = [1, true]
    //元组可以被方法越界(越界的值必须符合之前的类型限定)
    tuple1[1] = false
}
{
    //枚举类型 red等于0  0等于red
    enum Color {
        red,
        blue,
        yellow,
        pink
    }
}
{
    // any 可以是任何类型，通常为了接受一个无法预估的数据类型使用，代码里最好不要头any数据类型
    let any1: any = '1'
    any1 = 2
    any1 = true
    any1 = {}
    any1 = []
}
{
    // void类型，一般出现与函数没有返回值
    function fn1(x: (string | number)): void {
        // return '1'
    }
    fn1(1)
    // fn('1')
}
{
    //类型断言
    function fn2(x: (string | number)) {
        // return '1'
        if ((x as string).length) {
            return (<string>x).length
        } else {
            return x.toString().length
        }
    }
    fn2(1)
}
{
    //1.接口用来定义一个对象的类型
    //在定义类型的时候 属性和类型都是固定的
    interface obj1type {
        name: string,
        age: number
    }
    const obj: obj1type = {
        name: 'xiaoming',
        age: 18
    }
    //2. ?:可选属性
    interface obj2type {
        name: string,
        age: number,
        sex?:any
    }
    const obj1: obj2type = {
        name: 'xiaoming',
        age: 18,
        sex:'男'//sex属性可能存在可能不存在
    }
    //3.对象中有数组、
    type objArr = number[]
    interface obj3type {
        name:string,
        age:number,
        score:objArr
    }
    const obj3:obj3type={
        name: 'xiaoming',
        age: 18,
        score:[1,2,3]
    }
    //4.对象中有对象
    interface obj4Type {
        name: string,
        age: number,
        other: obj4OtherType
      }
      
    interface obj4OtherType {
        height:number,
        weight:number,
        girlFri:string[]
    }
    const obj4:obj4Type={
        name:'xiaoming',
        age:19,
        other:{
            height:188,
            weight:188,
            girlFri:['lily','lucy','xiaomming']
        }
    }
    //只读属性、
    interface obj5Type{
        name:string,
        readonly age:number
    }
    const obj5:obj5Type={
        name:'xiaoming',
        age:18
    }
    // obj5.age=10

}


